{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "JndnmDMp66FL"
   },
   "source": [
    "#### Copyright 2017 Google LLC."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "both",
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "hMqWDc_m6rUC"
   },
   "outputs": [],
   "source": [
    "# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
    "# you may not use this file except in compliance with the License.\n",
    "# You may obtain a copy of the License at\n",
    "#\n",
    "# https://www.apache.org/licenses/LICENSE-2.0\n",
    "#\n",
    "# Unless required by applicable law or agreed to in writing, software\n",
    "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
    "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
    "# See the License for the specific language governing permissions and\n",
    "# limitations under the License."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "rHLcriKWLRe4"
   },
   "source": [
    " # Pandas 简介"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "QvJBqX8_Bctk"
   },
   "source": [
    "**学习目标：**\n",
    "  * 大致了解 *pandas* 库的 `DataFrame` 和 `Series` 数据结构\n",
    "  * 存取和处理 `DataFrame` 和 `Series` 中的数据\n",
    "  * 将 CSV 数据导入 pandas 库的 `DataFrame`\n",
    "  * 对 `DataFrame` 重建索引来随机打乱数据"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TIFJ83ZTBctl"
   },
   "source": [
    " [*pandas*](http://pandas.pydata.org/) 是一种列存数据分析 API。它是用于处理和分析输入数据的强大工具，很多机器学习框架都支持将 *pandas* 数据结构作为输入。\n",
    "虽然全方位介绍 *pandas* API 会占据很长篇幅，但它的核心概念非常简单，我们会在下文中进行说明。有关更完整的参考，请访问 [*pandas* 文档网站](http://pandas.pydata.org/pandas-docs/stable/index.html)，其中包含丰富的文档和教程资源。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "s_JOISVgmn9v"
   },
   "source": [
    " ## 基本概念\n",
    "\n",
    "以下行导入了 *pandas* API 并输出了相应的 API 版本："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 51,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 981,
     "status": "ok",
     "timestamp": 1520090413841,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "aSRYu62xUi3g",
    "outputId": "07f7da8a-5fc2-4e56-f241-38e3498478a1"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the version is: 0.22.0\n",
      "test2\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "print('the version is:',pd.__version__)\n",
    "print('test2')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "daQreKXIUslr"
   },
   "source": [
    " *pandas* 中的主要数据结构被实现为以下两类：\n",
    "\n",
    "  * **`DataFrame`**，您可以将它想象成一个关系型数据表格，其中包含多个行和已命名的列。\n",
    "  * **`Series`**，它是单一列。`DataFrame` 中包含一个或多个 `Series`，每个 `Series` 均有一个名称。\n",
    "\n",
    "数据框架是用于数据操控的一种常用抽象实现形式。[Spark](https://spark.apache.org/) 和 [R](https://www.r-project.org/about.html) 中也有类似的实现。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "fjnAk1xcU0yc"
   },
   "source": [
    " 创建 `Series` 的一种方法是构建 `Series` 对象。例如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 153,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1080,
     "status": "ok",
     "timestamp": 1520090504433,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "DFZ42Uq7UFDj",
    "outputId": "fdd71986-e139-4acc-9339-f3e0c7ef4a72"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    San Francisco\n",
      "1         San Jose\n",
      "2       Sacramento\n",
      "dtype: object\n",
      "0    wangkaixuan\n",
      "1            wkx\n",
      "2          iroan\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "pds = pd.Series(['San Francisco', 'San Jose', 'Sacramento'])\n",
    "print(pds)\n",
    "\n",
    "pds1 = pd.Series(['wangkaixuan','wkx','iroan'])\n",
    "print(pds1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "U5ouUp1cU6pC"
   },
   "source": [
    " 您可以将映射 `string` 列名称的 `dict` 传递到它们各自的 `Series`，从而创建`DataFrame`对象。如果 `Series` 在长度上不一致，系统会用特殊的 [NA/NaN](http://pandas.pydata.org/pandas-docs/stable/missing_data.html) 值填充缺失的值。例如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 153,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1237,
     "status": "ok",
     "timestamp": 1520091006421,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "avgr6GfiUh8t",
    "outputId": "4a017c49-7b71-4b0d-b318-0faa7c65939c"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "       City name  Population\n",
      "0  San Francisco      852469\n",
      "1       San Jose     1015785\n",
      "2     Sacramento      485199\n",
      "   age          name\n",
      "0   23   wangkaixuan\n",
      "1   22  chengangrong\n",
      "2    6       longhao\n"
     ]
    }
   ],
   "source": [
    "city_names = pd.Series(['San Francisco', 'San Jose', 'Sacramento'])\n",
    "population = pd.Series([852469, 1015785, 485199])\n",
    "\n",
    "temp = pd.DataFrame({ 'City name': city_names, 'Population': population })\n",
    "print(temp)\n",
    "\n",
    "\n",
    "names=pd.Series(['wangkaixuan','chengangrong','longhao'])\n",
    "age = pd.Series([23,22,6])\n",
    "g_age = pd.DataFrame({'name':names,'age':age})\n",
    "print(g_age)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "oa5wfZT7VHJl"
   },
   "source": [
    " 但是在大多数情况下，您需要将整个文件加载到 `DataFrame` 中。下面的示例加载了一个包含加利福尼亚州住房数据的文件。请运行以下单元格以加载数据，并创建特征定义："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 317,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1135,
     "status": "ok",
     "timestamp": 1520091070923,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "av6RYOraVG1V",
    "outputId": "ee545939-0873-44e1-88e9-326054b8e5e8"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>housing_median_age</th>\n",
       "      <th>total_rooms</th>\n",
       "      <th>total_bedrooms</th>\n",
       "      <th>population</th>\n",
       "      <th>households</th>\n",
       "      <th>median_income</th>\n",
       "      <th>median_house_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "      <td>17000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>-119.562108</td>\n",
       "      <td>35.625225</td>\n",
       "      <td>28.589353</td>\n",
       "      <td>2643.664412</td>\n",
       "      <td>539.410824</td>\n",
       "      <td>1429.573941</td>\n",
       "      <td>501.221941</td>\n",
       "      <td>3.883578</td>\n",
       "      <td>207300.912353</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>2.005166</td>\n",
       "      <td>2.137340</td>\n",
       "      <td>12.586937</td>\n",
       "      <td>2179.947071</td>\n",
       "      <td>421.499452</td>\n",
       "      <td>1147.852959</td>\n",
       "      <td>384.520841</td>\n",
       "      <td>1.908157</td>\n",
       "      <td>115983.764387</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-124.350000</td>\n",
       "      <td>32.540000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.499900</td>\n",
       "      <td>14999.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-121.790000</td>\n",
       "      <td>33.930000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>1462.000000</td>\n",
       "      <td>297.000000</td>\n",
       "      <td>790.000000</td>\n",
       "      <td>282.000000</td>\n",
       "      <td>2.566375</td>\n",
       "      <td>119400.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>-118.490000</td>\n",
       "      <td>34.250000</td>\n",
       "      <td>29.000000</td>\n",
       "      <td>2127.000000</td>\n",
       "      <td>434.000000</td>\n",
       "      <td>1167.000000</td>\n",
       "      <td>409.000000</td>\n",
       "      <td>3.544600</td>\n",
       "      <td>180400.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>-118.000000</td>\n",
       "      <td>37.720000</td>\n",
       "      <td>37.000000</td>\n",
       "      <td>3151.250000</td>\n",
       "      <td>648.250000</td>\n",
       "      <td>1721.000000</td>\n",
       "      <td>605.250000</td>\n",
       "      <td>4.767000</td>\n",
       "      <td>265000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>-114.310000</td>\n",
       "      <td>41.950000</td>\n",
       "      <td>52.000000</td>\n",
       "      <td>37937.000000</td>\n",
       "      <td>6445.000000</td>\n",
       "      <td>35682.000000</td>\n",
       "      <td>6082.000000</td>\n",
       "      <td>15.000100</td>\n",
       "      <td>500001.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          longitude      latitude  housing_median_age   total_rooms  \\\n",
       "count  17000.000000  17000.000000        17000.000000  17000.000000   \n",
       "mean    -119.562108     35.625225           28.589353   2643.664412   \n",
       "std        2.005166      2.137340           12.586937   2179.947071   \n",
       "min     -124.350000     32.540000            1.000000      2.000000   \n",
       "25%     -121.790000     33.930000           18.000000   1462.000000   \n",
       "50%     -118.490000     34.250000           29.000000   2127.000000   \n",
       "75%     -118.000000     37.720000           37.000000   3151.250000   \n",
       "max     -114.310000     41.950000           52.000000  37937.000000   \n",
       "\n",
       "       total_bedrooms    population    households  median_income  \\\n",
       "count    17000.000000  17000.000000  17000.000000   17000.000000   \n",
       "mean       539.410824   1429.573941    501.221941       3.883578   \n",
       "std        421.499452   1147.852959    384.520841       1.908157   \n",
       "min          1.000000      3.000000      1.000000       0.499900   \n",
       "25%        297.000000    790.000000    282.000000       2.566375   \n",
       "50%        434.000000   1167.000000    409.000000       3.544600   \n",
       "75%        648.250000   1721.000000    605.250000       4.767000   \n",
       "max       6445.000000  35682.000000   6082.000000      15.000100   \n",
       "\n",
       "       median_house_value  \n",
       "count        17000.000000  \n",
       "mean        207300.912353  \n",
       "std         115983.764387  \n",
       "min          14999.000000  \n",
       "25%         119400.000000  \n",
       "50%         180400.000000  \n",
       "75%         265000.000000  \n",
       "max         500001.000000  "
      ]
     },
     "execution_count": 11,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "california_housing_dataframe = pd.read_csv(\"https://storage.googleapis.com/ml_universities/california_housing_train.csv\", sep=\",\")\n",
    "california_housing_dataframe.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "WrkBjfz5kEQu"
   },
   "source": [
    " 上面的示例使用 `DataFrame.describe` 来显示关于 `DataFrame` 的有趣统计信息。另一个实用函数是 `DataFrame.head`，它显示 `DataFrame` 的前几个记录："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 224,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1147,
     "status": "ok",
     "timestamp": 1520091141066,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "s3ND3bgOkB5k",
    "outputId": "81b74e90-c234-4bd5-ea05-03a00e300631"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>housing_median_age</th>\n",
       "      <th>total_rooms</th>\n",
       "      <th>total_bedrooms</th>\n",
       "      <th>population</th>\n",
       "      <th>households</th>\n",
       "      <th>median_income</th>\n",
       "      <th>median_house_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-114.31</td>\n",
       "      <td>34.19</td>\n",
       "      <td>15.0</td>\n",
       "      <td>5612.0</td>\n",
       "      <td>1283.0</td>\n",
       "      <td>1015.0</td>\n",
       "      <td>472.0</td>\n",
       "      <td>1.4936</td>\n",
       "      <td>66900.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-114.47</td>\n",
       "      <td>34.40</td>\n",
       "      <td>19.0</td>\n",
       "      <td>7650.0</td>\n",
       "      <td>1901.0</td>\n",
       "      <td>1129.0</td>\n",
       "      <td>463.0</td>\n",
       "      <td>1.8200</td>\n",
       "      <td>80100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-114.56</td>\n",
       "      <td>33.69</td>\n",
       "      <td>17.0</td>\n",
       "      <td>720.0</td>\n",
       "      <td>174.0</td>\n",
       "      <td>333.0</td>\n",
       "      <td>117.0</td>\n",
       "      <td>1.6509</td>\n",
       "      <td>85700.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-114.57</td>\n",
       "      <td>33.64</td>\n",
       "      <td>14.0</td>\n",
       "      <td>1501.0</td>\n",
       "      <td>337.0</td>\n",
       "      <td>515.0</td>\n",
       "      <td>226.0</td>\n",
       "      <td>3.1917</td>\n",
       "      <td>73400.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-114.57</td>\n",
       "      <td>33.57</td>\n",
       "      <td>20.0</td>\n",
       "      <td>1454.0</td>\n",
       "      <td>326.0</td>\n",
       "      <td>624.0</td>\n",
       "      <td>262.0</td>\n",
       "      <td>1.9250</td>\n",
       "      <td>65500.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   longitude  latitude  housing_median_age  total_rooms  total_bedrooms  \\\n",
       "0    -114.31     34.19                15.0       5612.0          1283.0   \n",
       "1    -114.47     34.40                19.0       7650.0          1901.0   \n",
       "2    -114.56     33.69                17.0        720.0           174.0   \n",
       "3    -114.57     33.64                14.0       1501.0           337.0   \n",
       "4    -114.57     33.57                20.0       1454.0           326.0   \n",
       "\n",
       "   population  households  median_income  median_house_value  \n",
       "0      1015.0       472.0         1.4936             66900.0  \n",
       "1      1129.0       463.0         1.8200             80100.0  \n",
       "2       333.0       117.0         1.6509             85700.0  \n",
       "3       515.0       226.0         3.1917             73400.0  \n",
       "4       624.0       262.0         1.9250             65500.0  "
      ]
     },
     "execution_count": 12,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "california_housing_dataframe.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "w9-Es5Y6laGd"
   },
   "source": [
    " *pandas* 的另一个强大功能是绘制图表。例如，借助 `DataFrame.hist`，您可以快速了解一个列中值的分布：\n",
    "\n",
    "---\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 396,
     "output_extras": [
      {},
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1405,
     "status": "ok",
     "timestamp": 1520091442413,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "nqndFVXVlbPN",
    "outputId": "edda7f05-a6c1-4ea3-c03b-7b1e7021d4a9"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f4a7a3ff1d0>]],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 22,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAe8AAAFZCAYAAACxGqelAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3X9Ulfdhx/HPhcsdI71UIPfa2iUu\npk1wLWCMHRUkkSj+oOtqmuGAYZoGF13QmI5EKbNqjstEDUma1NVoYuXoVBKapdTmgMs0HhtvyOjd\nYdozj7PpNoIO7o0gyg9BePZHj/eEiFGvKHwf3q+/5Hu/z3O/H58TP/f53suNw7IsSwAAwBgRw70A\nAABwbShvAAAMQ3kDAGAYyhsAAMNQ3gAAGIbyBgDAMJQ3AACGobwBQ7z++utDMuejjz7Sn/zJnwzF\nkgAME8obMEBfX582bNhw3XMA2APlDRjge9/7ns6ePas5c+bogw8+UGFhoWbPnq0/+7M/01tvvXXJ\nnMbGRn344YfKy8vT3LlzlZWVpb17917Tcy5YsEAvvPCC5s6dK7/fr7a2Ni1btkyzZ89Wdna2tmzZ\nEppbV1enBx98UHPmzFFOTo6OHDkiSXrzzTf1xBNPqLi4WNOnT9f3vvc91dfXKzc3V2lpaaq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aevWrfJ6vaGx683S09Ojpqam0A7KxXMMd67BmJTr61//un70ox9J\nkmJjY9XV1WWLazVYrr6+vkvmmZQrOztbf/3Xfy1JOnXqlMaOHWv8tRos02BMyjSURl15B4NBxcXF\nhX6++LWsI92JEye0ePFi5eXl6b333lNXV5dcLpckKSEhQYFAQMFgUPHx8aFjLmb75HhERIQcDod6\nenqGJYfT6VR0dPSAsevNEgwGFRsbG5p78Rw302C5JGnnzp16+OGH9f3vf1+nT582KldkZKRiYmIk\nSVVVVbrvvvtsca0GyxUZGWn0tbooNzdXTz31lEpLS21xraSBmSSz/5saSqPyPe9Psgz4Tbk//uM/\n1pIlSzR37lw1Njbq4YcfHnCncLkM1zo+EgxFlpGS79vf/rbGjBmjiRMnasuWLfrxj3+se+65Z8Ac\nE3K98847qqqq0rZt2zRr1qwrrseETNLAXEePHrXFtdqzZ4/+8z//U08//fSANZh8rT6ZqbS01BbX\naSiMujtvE7+WdezYscrOzpbD4dDtt9+uW2+9VWfOnFF3d7ckqbm5WV6vd9BsF8cvvrrs7e2VZVmh\nV+QjQUxMzHVl8Xg8amtrC829eI7hNnXqVE2cOFGS9MADD+j48ePG5Tp06JA2b96srVu3yu122+Za\nfTqX6dfq6NGjOnXqlCRp4sSJ6uvr0y233GL0tRos01133WX0dRpKo668Tfxa1urqar322muSpEAg\noI8//ljf+c53Qjn27dunjIwMpaSk6MiRI2pvb1dHR4f8fr+mTJmi9PR01dTUSJIOHDig1NTUYcsy\nmLS0tOvKEhUVpQkTJqi+vn7AOYbb0qVL1djYKOn37+t/5StfMSrX2bNntWHDBr3yyiuhT/fa4VoN\nlsv0a1VfX69t27ZJ+v1bg52dncZfq8EyrVq1yujrNJRG5TesPffcc6qvrw99LWtiYuJwL+kznTt3\nTk899ZTa29vV29urJUuWaOLEiVqxYoXOnz+vcePGad26dYqKilJNTY1ee+01ORwOFRQU6M///M/V\n19enlStX6r//+7/lcrlUVlamL37xi8OS5ejRo1q/fr2amprkdDo1duxYPffccyopKbmuLCdOnNCq\nVavU39+vlJQU/eAHPxj2XAUFBdqyZYv+8A//UDExMVq3bp0SEhKMyVVZWamXX35Zd9xxR2isrKxM\nK1euNPpaDZbrO9/5jnbu3Gnsteru7tbf/d3f6dSpU+ru7taSJUv0ta997br/jRhpmWJiYrRx40Zj\nr9NQGpXlDQCAyUbdtjkAAKajvAEAMAzlDQCAYShvAAAMQ3kDAGAYyhsAAMNQ3gAAGIbyBgDAMP8P\nkwiEYQN5UiwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f4a7a59e250>"
      ]
     },
     "metadata": {
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#california_housing_dataframe.hist('housing_median_age')\n",
    "\n",
    "california_housing_dataframe.hist('total_rooms')\n",
    "# print(hist)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "XtYZ7114n3b-"
   },
   "source": [
    " ## 访问数据\n",
    "\n",
    "您可以使用熟悉的 Python dict/list 指令访问 `DataFrame` 数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 119,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 830,
     "status": "ok",
     "timestamp": 1520091796396,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "_TFm7-looBFF",
    "outputId": "bcfeab3e-3beb-4ad7-b956-43a1d6f817ed"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.series.Series'>\n",
      "('c1=', 0    San Francisco\n",
      "1         San Jose\n",
      "2       Sacramento\n",
      "Name: City name, dtype: object)\n",
      "('c1=', 'Sacramento')\n"
     ]
    }
   ],
   "source": [
    "cities = pd.DataFrame({ 'City name': city_names, 'Population': population })\n",
    "print type(cities['City name'])\n",
    "c1 = cities['City name']\n",
    "print('c1=',c1)\n",
    "print('c1=',c1[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "V5L6xacLoxyv"
   },
   "outputs": [],
   "source": [
    "print type(cities['City name'][1])\n",
    "cities['City name'][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 128,
     "output_extras": [
      {},
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1151,
     "status": "ok",
     "timestamp": 1520091806476,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "gcYX1tBPugZl",
    "outputId": "97681ad6-4e6f-4bd3-bf69-b99317de5946"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>San Francisco</td>\n",
       "      <td>852469</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       City name  Population\n",
       "0  San Francisco      852469\n",
       "1       San Jose     1015785"
      ]
     },
     "execution_count": 28,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print type(cities[0:2])\n",
    "cities[0:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "65g1ZdGVjXsQ"
   },
   "source": [
    " 此外，*pandas* 针对高级[索引和选择](http://pandas.pydata.org/pandas-docs/stable/indexing.html)提供了极其丰富的 API（数量过多，此处无法逐一列出）。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "RM1iaD-ka3Y1"
   },
   "source": [
    " ## 操控数据\n",
    "\n",
    "您可以向 `Series` 应用 Python 的基本运算指令。例如："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 85,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 971,
     "status": "ok",
     "timestamp": 1520091901708,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "XWmyCFJ5bOv-",
    "outputId": "be364619-da53-4912-8525-c49b5d0a6847"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     852\n",
       "1    1015\n",
       "2     485\n",
       "dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "population // 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TQzIVnbnmWGM"
   },
   "source": [
    " [NumPy](http://www.numpy.org/) 是一种用于进行科学计算的常用工具包。*pandas* `Series` 可用作大多数 NumPy 函数的参数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 153,
     "output_extras": [
      {},
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1118,
     "status": "ok",
     "timestamp": 1520092074976,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "ko6pLK6JmkYP",
    "outputId": "9b86700f-5440-4301-e267-d6f578f138a0"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0     852469\n",
      "1    1015785\n",
      "2     485199\n",
      "dtype: int64\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0    13.655892\n",
       "1    13.831172\n",
       "2    13.092314\n",
       "dtype: float64"
      ]
     },
     "execution_count": 34,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "print population\n",
    "np.log(population)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "xmxFuQmurr6d"
   },
   "source": [
    " 对于更复杂的单列转换，您可以使用 `Series.apply`。像 Python [映射函数](https://docs.python.org/2/library/functions.html#map)一样，`Series.apply` 将以参数形式接受 [lambda 函数](https://docs.python.org/2/tutorial/controlflow.html#lambda-expressions)，而该函数会应用于每个值。\n",
    "\n",
    "下面的示例创建了一个指明 `population` 是否超过 100 万的新 `Series`："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 85,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 981,
     "status": "ok",
     "timestamp": 1520092146694,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "Fc1DvPAbstjI",
    "outputId": "57c8a525-6f2e-4ca2-d5c1-26a3aa369cfe"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1     True\n",
       "2    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 35,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "population.apply(lambda val: val > 1000000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "ZeYYLoV9b9fB"
   },
   "source": [
    " \n",
    "`DataFrames` 的修改方式也非常简单。例如，以下代码向现有 `DataFrame` 添加了两个 `Series`："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 142,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1194,
     "status": "ok",
     "timestamp": 1520092326041,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "0gCEX99Hb8LR",
    "outputId": "432bcbab-7416-403e-dfba-665b4a119163"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "      <th>Area square miles</th>\n",
       "      <th>Population density</th>\n",
       "      <th>wangkaixuan's test</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>San Francisco</td>\n",
       "      <td>852469</td>\n",
       "      <td>46.87</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>18187.945381</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785</td>\n",
       "      <td>176.53</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>5754.177760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sacramento</td>\n",
       "      <td>485199</td>\n",
       "      <td>97.92</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>4955.055147</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       City name  Population  Area square miles  Population density  \\\n",
       "0  San Francisco      852469              46.87        18187.945381   \n",
       "1       San Jose     1015785             176.53         5754.177760   \n",
       "2     Sacramento      485199              97.92         4955.055147   \n",
       "\n",
       "   wangkaixuan's test  \n",
       "0        18187.945381  \n",
       "1         5754.177760  \n",
       "2         4955.055147  "
      ]
     },
     "execution_count": 39,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities['Area square miles'] = pd.Series([46.87, 176.53, 97.92])\n",
    "cities['Population density'] = cities['Population'] / cities['Area square miles']\n",
    "cities\n",
    "cities['wangkaixuan\\'s test'] = cities['Population'] / cities['Area square miles']\n",
    "cities       \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "6qh63m-ayb-c"
   },
   "source": [
    " ## 练习 1\n",
    "\n",
    "通过添加一个新的布尔值列（当且仅当以下*两项*均为 True 时为 True）修改 `cities` 表格：\n",
    "\n",
    "  * 城市以圣人命名。\n",
    "  * 城市面积大于 50 平方英里。\n",
    "\n",
    "**注意：**布尔值 `Series` 是使用“按位”而非传统布尔值“运算符”组合的。例如，执行*逻辑与*时，应使用 `&`，而不是 `and`。\n",
    "\n",
    "**提示：**\"San\" 在西班牙语中意为 \"saint\"。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "zCOn8ftSyddH"
   },
   "outputs": [],
   "source": [
    "# Your code here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "YHIWvc9Ms-Ll"
   },
   "source": [
    " ### 解决方案\n",
    "\n",
    "点击下方，查看解决方案。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 142,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1142,
     "status": "ok",
     "timestamp": 1520092463562,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "T5OlrqtdtCIb",
    "outputId": "e18f4ac4-d4af-4ba0-cc3c-58c03b538423"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "      <th>Area square miles</th>\n",
       "      <th>Population density</th>\n",
       "      <th>wangkaixuan's test</th>\n",
       "      <th>Is wide and has saint name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>San Francisco</td>\n",
       "      <td>852469</td>\n",
       "      <td>46.87</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785</td>\n",
       "      <td>176.53</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sacramento</td>\n",
       "      <td>485199</td>\n",
       "      <td>97.92</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       City name  Population  Area square miles  Population density  \\\n",
       "0  San Francisco      852469              46.87        18187.945381   \n",
       "1       San Jose     1015785             176.53         5754.177760   \n",
       "2     Sacramento      485199              97.92         4955.055147   \n",
       "\n",
       "   wangkaixuan's test  Is wide and has saint name  \n",
       "0        18187.945381                       False  \n",
       "1         5754.177760                        True  \n",
       "2         4955.055147                       False  "
      ]
     },
     "execution_count": 40,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以圣人命名的含义是以‘圣人’开头的字符串\n",
    "cities['Is wide and has saint name'] = (cities['Area square miles'] > 50) & cities['City name'].apply(lambda name: name.startswith('San'))\n",
    "cities"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "f-xAOJeMiXFB"
   },
   "source": [
    " ## 索引\n",
    "`Series` 和 `DataFrame` 对象也定义了 `index` 属性，该属性会向每个 `Series` 项或 `DataFrame` 行赋一个标识符值。\n",
    "\n",
    "默认情况下，在构造时，*pandas* 会赋可反映源数据顺序的索引值。索引值在创建后是稳定的；也就是说，它们不会因为数据重新排序而发生改变。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1161,
     "status": "ok",
     "timestamp": 1520092616416,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "2684gsWNinq9",
    "outputId": "5cc84af9-1240-4ea0-e983-fcb9c267ff66"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=3, step=1)"
      ]
     },
     "execution_count": 41,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_names.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 956,
     "status": "ok",
     "timestamp": 1520092624093,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "F_qPe2TBjfWd",
    "outputId": "e175ef89-7866-417b-814f-529fd11465bc"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=3, step=1)"
      ]
     },
     "execution_count": 42,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities.index"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "hp2oWY9Slo_h"
   },
   "source": [
    " 调用 `DataFrame.reindex` 以手动重新排列各行的顺序。例如，以下方式与按城市名称排序具有相同的效果："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 142,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1049,
     "status": "ok",
     "timestamp": 1520092631154,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "sN0zUzSAj-U1",
    "outputId": "4bbee8e7-997f-4c2e-96c4-aceb0f5ce655"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "      <th>Area square miles</th>\n",
       "      <th>Population density</th>\n",
       "      <th>wangkaixuan's test</th>\n",
       "      <th>Is wide and has saint name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sacramento</td>\n",
       "      <td>485199</td>\n",
       "      <td>97.92</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>San Francisco</td>\n",
       "      <td>852469</td>\n",
       "      <td>46.87</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785</td>\n",
       "      <td>176.53</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       City name  Population  Area square miles  Population density  \\\n",
       "2     Sacramento      485199              97.92         4955.055147   \n",
       "0  San Francisco      852469              46.87        18187.945381   \n",
       "1       San Jose     1015785             176.53         5754.177760   \n",
       "\n",
       "   wangkaixuan's test  Is wide and has saint name  \n",
       "2         4955.055147                       False  \n",
       "0        18187.945381                       False  \n",
       "1         5754.177760                        True  "
      ]
     },
     "execution_count": 43,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities.reindex([2, 0, 1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "-GQFz8NZuS06"
   },
   "source": [
    " 重建索引是一种随机排列 `DataFrame` 的绝佳方式。在下面的示例中，我们会取用类似数组的索引，然后将其传递至 NumPy 的 `random.permutation` 函数，该函数会随机排列其值的位置。如果使用此重新随机排列的数组调用 `reindex`，会导致 `DataFrame` 行以同样的方式随机排列。\n",
    "尝试多次运行以下单元格！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 142,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1088,
     "status": "ok",
     "timestamp": 1520092721254,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "mF8GC0k8uYhz",
    "outputId": "1472e8ed-e31b-4d01-ebc3-c76ce032929c"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "      <th>Area square miles</th>\n",
       "      <th>Population density</th>\n",
       "      <th>wangkaixuan's test</th>\n",
       "      <th>Is wide and has saint name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785</td>\n",
       "      <td>176.53</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>San Francisco</td>\n",
       "      <td>852469</td>\n",
       "      <td>46.87</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>18187.945381</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sacramento</td>\n",
       "      <td>485199</td>\n",
       "      <td>97.92</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       City name  Population  Area square miles  Population density  \\\n",
       "1       San Jose     1015785             176.53         5754.177760   \n",
       "0  San Francisco      852469              46.87        18187.945381   \n",
       "2     Sacramento      485199              97.92         4955.055147   \n",
       "\n",
       "   wangkaixuan's test  Is wide and has saint name  \n",
       "1         5754.177760                        True  \n",
       "0        18187.945381                       False  \n",
       "2         4955.055147                       False  "
      ]
     },
     "execution_count": 46,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities.reindex(np.random.permutation(cities.index))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "fSso35fQmGKb"
   },
   "source": [
    " 有关详情，请参阅[索引文档](http://pandas.pydata.org/pandas-docs/stable/indexing.html#index-objects)。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "8UngIdVhz8C0"
   },
   "source": [
    " ## 练习 2\n",
    "\n",
    "`reindex` 方法允许使用未包含在原始 `DataFrame` 索引值中的索引值。请试一下，看看如果使用此类值会发生什么！您认为允许此类值的原因是什么？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 142,
     "output_extras": [
      {}
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1312,
     "status": "ok",
     "timestamp": 1520092765007,
     "user": {
      "displayName": "",
      "photoUrl": "",
      "userId": ""
     },
     "user_tz": -480
    },
    "id": "PN55GrDX0jzO",
    "outputId": "d6763254-e1ee-4adf-91a8-f9a27bcf2300"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>City name</th>\n",
       "      <th>Population</th>\n",
       "      <th>Area square miles</th>\n",
       "      <th>Population density</th>\n",
       "      <th>wangkaixuan's test</th>\n",
       "      <th>Is wide and has saint name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sacramento</td>\n",
       "      <td>485199.0</td>\n",
       "      <td>97.92</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>4955.055147</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>San Jose</td>\n",
       "      <td>1015785.0</td>\n",
       "      <td>176.53</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>5754.177760</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    City name  Population  Area square miles  Population density  \\\n",
       "2  Sacramento    485199.0              97.92         4955.055147   \n",
       "4         NaN         NaN                NaN                 NaN   \n",
       "1    San Jose   1015785.0             176.53         5754.177760   \n",
       "\n",
       "   wangkaixuan's test Is wide and has saint name  \n",
       "2         4955.055147                      False  \n",
       "4                 NaN                        NaN  \n",
       "1         5754.177760                       True  "
      ]
     },
     "execution_count": 47,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Your code here\n",
    "cities.reindex([2, 4, 1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TJffr5_Jwqvd"
   },
   "source": [
    " ### 解决方案\n",
    "\n",
    "点击下方，查看解决方案。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "GH05D3YGmaGB"
   },
   "source": [
    "# 新段落"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "8oSvi2QWwuDH"
   },
   "source": [
    " 如果您的 `reindex` 输入数组包含原始 `DataFrame` 索引值中没有的值，`reindex` 会为此类“丢失的”索引添加新行，并在所有对应列中填充 `NaN` 值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "id": "yBdkucKCwy4x"
   },
   "outputs": [],
   "source": [
    "cities.reindex([0, 4, 5, 2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "2l82PhPbwz7g"
   },
   "source": [
    " 这种行为是可取的，因为索引通常是从实际数据中提取的字符串（请参阅 [*pandas* reindex 文档](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reindex.html)，查看索引值是浏览器名称的示例）。\n",
    "\n",
    "在这种情况下，如果允许出现“丢失的”索引，您将可以轻松使用外部列表重建索引，因为您不必担心会将输入清理掉。"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [
    "JndnmDMp66FL",
    "YHIWvc9Ms-Ll",
    "TJffr5_Jwqvd"
   ],
   "default_view": {},
   "name": "“intro_to_pandas.ipynb”的副本",
   "provenance": [
    {
     "file_id": "/v2/external/notebooks/mlcc/intro_to_pandas.ipynb",
     "timestamp": 1520092966735
    }
   ],
   "version": "0.3.2",
   "views": {}
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
